<template>
      <a-modal v-model:visible="visible" title="Modal Form" @cancel="handleCancel" @before-ok="handleBeforeOk">
        <a-form :model="form">
          <a-form-item field="holidayFlag" label="日期类型">
            <a-select v-model="form.holidayFlag">
              <a-option value="0">工作日</a-option>
              <a-option value="1">双休日</a-option>
              <a-option value="2">国家法定节假日</a-option>
            </a-select>
          </a-form-item>
        </a-form>
      </a-modal>
  </template>
  
  <script setup lang="ts">
  import { ref, watch, computed, onMounted } from 'vue';
  import { insertHolidaySetting } from '@/apis/system/holiday-setting'
  
  // 定义响应式数据
  const visible = ref<boolean>(false);
  const form = reactive({
    holidayFlag: '0',
    holidayDate: ''
  });
   // 定义事件
  const emit = defineEmits<{
       (e: 'save-success'): void
   }>()

  const handleBeforeOk = (done) => {
    console.log(form);
    insertHolidaySetting(form);
    window.setTimeout(() => {
        emit('save-success')
        done()
    }, 1000)
  };

  const handleCancel = () => {
    visible.value = false;
  }

  const onOpen = (holidayDate, holidayFlag) => {
    visible.value = true;
    form.holidayFlag = holidayFlag;
    form.holidayDate = holidayDate;
  }
  
  defineExpose({ onOpen })
  
  </script>